#ifndef FORTRESS_ENGINE_H
#define FORTRESS_ENGINE_H
#include <string>
#include <fstream>
#include <map>
#include "eventhandler.h"


//#include <boost/archive/tmpdir.hpp>

//#include <boost/archive/text_iarchive.hpp>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

//#include <boost/serialization/base_object.hpp>
//#include <boost/serialization/utility.hpp>
//#include <boost/serialization/list.hpp>
//#include <boost/serialization/assume_abstract.hpp>
namespace fortress
{

	class character;
	class inputController;
	class mapController;
	class characterController;
	class messageController;
	class monster;
	class player;
	class view;
	class map;
	class items;

	class Engine// : public eventReceiver
	{
	private:
		friend class boost::serialization::access;
		template<class Archive>
		void serialize(Archive & ar, const unsigned int version);
		inputController *input;
		mapController * gameMaps;
		characterController *characters;
		monster * monsterAI;
		player * pc;
		//messageController *messages;
		view *gameView;
		std::map<int,items*> * itemInfo;
//		Engine(const Engine &);             // intentionally undefined
//		Engine & operator=(const Engine &); // intentionally undefined
	public:
		Engine();
		Engine(std::ifstream &);
		~Engine();

		// Returns the message handling interface
//		static eventReceiver & getEventHandler();
		// Creates a window to render the game onto
		void createWindow(int x, int y, std::string *title, bool fullscreen=false); 
		// Sets the window title
		void setWindowTitle(std::string *title); 
		// Checks to see if the game is over, due to the player quitting or losing. Returns 1 on end
		bool isGameOver();	
		void endGame();
		// Get player input, and then send it to the character the player controls
		bool waitForInput();
		// Updates the game scene, then renders the screen
		// If playerTurn is false, the player did not take a turn.  Act accordingly
		void updateWorld(bool playerTurn); 
		// Create the player character, assigning all necessary data and giving the input object its address
		void createPlayer();
		void loadPlayer();
		// Init a new game
		void createWorld(); 
		// Render the game scene without updating the game state
		void redraw();

	};
	void saveGame(Engine const &game, const char * filename);
};
#endif